SQLite
The package provides an interface to SQLite.
Example
Open a connection, create a table, and insert a few rows:
let connection = open.unwrap;
let query = "
CREATE TABLE users (name TEXT, age INTEGER);
INSERT INTO users VALUES ('Alice', 42);
INSERT INTO users VALUES ('Bob', 69);
";
connection.execute.unwrap;
Select some rows and process them one by one as plain text, which is generally not efficient:
let query = "SELECT * FROM users WHERE age > 50";
connection
.iterate
.unwrap;
Run the same query but using a prepared statement, which is much more efficient than the previous technique:
use State;
let query = "SELECT * FROM users WHERE age > ?";
let mut statement = connection.prepare.unwrap;
statement.bind.unwrap;
while let Ok = statement.next
Run the same query but using a cursor, which is iterable:
let query = "SELECT * FROM users WHERE age > ?";
for row in connection
.prepare
.unwrap
.into_iter
.bind
.unwrap
.map
Contribution
Your contribution is highly appreciated. Do not hesitate to open an issue or a pull request. Note that any contribution submitted for inclusion in the project will be licensed according to the terms given in LICENSE.md.